package com.rock.code.common.util;

import java.util.Arrays;
import java.util.List;

/**
 * @author Marka
 * @date 2015/12/21
 * @Time 15:45
 * @Version 1.0
 */
public class CustomException extends Exception {
    private static final long serialVersionUID = 2455254156036803593L;
    private String errorInfo;
    private Throwable cause;
    private List<Object> params;

    @Override
	public Throwable getCause() {
        return this.cause;
    }

    public List<Object> getParams() {
        return params;
    }

    public CustomException(String errorInfo) {
        super(errorInfo);
        params = null;
        this.errorInfo = errorInfo;
    }

    public CustomException(String errorInfo, Object... param) {
        super(String.valueOf(errorInfo));
        initParam(errorInfo, param);
    }

    public CustomException(String errorInfo, Throwable cause) {
        super(cause);
        this.cause = cause;
        this.errorInfo = errorInfo;
    }

    public CustomException(String errorInfo, Throwable cause, Object... param0) {
        super(cause);
        this.cause = cause;
        initParam(errorInfo, param0);
    }

    private void initParam(String errorInfo, Object... param) {
        this.errorInfo = errorInfo;
        this.params = Arrays.asList(param);
    }

    public String getErrorInfo() {
        return errorInfo;
    }

    public void setErrorInfo(String errorInfo) {
        this.errorInfo = errorInfo;
    }
}
